package cn.tedu.blog.server.mapper;

import cn.tedu.blog.server.pojo.dto.ArticleHistoryDTO;
import cn.tedu.blog.server.pojo.dto.ArticleHistoryEditDTO;
import cn.tedu.blog.server.pojo.vo.ArticleHistoryVO;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ArticleHistoryMapper {
    
    // 新增浏览记录到b_history表
    int insertHistory(ArticleHistoryDTO articleHistoryDTO);
    
    // 根据userId查询历史浏览
    List<ArticleHistoryVO> listHistory(Long userId);
    
    // 根据userId和articleId查询
    LocalDateTime getByUserIdAndArticleId(@Param("userId") Long userId,
                                          @Param("arcileId") Long articleId);
    
    // 根据userId和articleId修改浏览时间
    int updateViewTime(ArticleHistoryEditDTO articleHistoryEditDTO);


    // 根据用户id查询浏览历史数量
    int countHistory(Long userId);

    // 根据userId和页面展示条数查询历史浏览
    List<ArticleHistoryVO> listArticleHistory(@Param("userId") Long userId, @Param("pageSize") Integer pageSize);

}
